<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateDeliveriesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('deliveries', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('order_id')->comment('[v1.0]订单id');
            $table->integer('type')->default(0)->comment('[v1.0]配送方式: 0 无需配送; 1 自提; 2+ 快递');
            
            // 地址信息
            $table->string('name')->nullable()->comment('[v1.0]姓名');
            $table->string('tel')->nullable()->comment('[v1.0]联系电话');
            $table->double('latitude')->nullable()->comment('[v1.0]纬度');
            $table->double('longitude')->nullable()->comment('[v1.0]经度');
            $table->string('community')->nullable()->comment('[v1.0]所在小区');
            $table->string('address_name')->nullable()->comment('[v1.0]位置名');
            $table->string('details')->nullable()->comment('[v1.0]详情地址');

            // 配送跟踪
            $table->string('tracking')->nullable()->comment('[v1.0]快递单号');
            $table->tinyInteger('status')->default(0)->comment('[v1.0]配送状态 0：等侍配送前提 1：已备货 2：已发货 3：已收货');
            $table->timestamp('send_time')->nullable()->comment('[v1.0]发货时间');
            $table->timestamp('complete_at')->nullable()->comment('[v1.0]客户收货时间');

            $table->timestamps();
            $table->softDeletes();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('deliveries');
    }
}
